package operation.JiChen;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Demo01 {
    public static void main(String[] args) {
        /*1.分析以下需求，并用代码实现：
	    (1)定义List集合，存入多个字符串
	    (2)删除集合中所有字符串"def"
	    (3)然后再利用迭代器遍历集合元素并输出*/
        //(1)定义List集合，存入多个字符串
        List<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bef");
        list.add("def");
        list.add("ddd");
        list.add("def");
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
            String next = it.next();
            if ("def".equals(next)) {
                it.remove();
            }
        }
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            System.out.println(next);
        }


    }
}
